﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using WinRTControl.Helpers;

namespace WinRTControl.Navigation
{
    internal sealed class JournalEntry : DependencyObject
    {
        #region SourceProperty

        private Uri _source;

        public Uri Source
        {
            get { return _source; }
            set
            {
                Guard.AreNotNull(value, "uri value");
                _source = value;
            }
        }


        #endregion


        #region NameAttacheToPageProperty

        public static string GetName(DependencyObject obj)
        {
            Guard.AreNotNull(obj, "obj");
            return (string)obj.GetValue(NameProperty);
        }

        public static void SetName(DependencyObject obj, string value)
        {
            Guard.AreNotNull(obj, "obj");
            obj.SetValue(NameProperty, value);
        }

        public String Name
        {
            get { return (String)GetValue(NameProperty); }
            set { SetValue(NameProperty, value); }
        }

        public static readonly DependencyProperty NameProperty =
            DependencyProperty.RegisterAttached("Name", typeof(string), typeof(JournalEntry), new PropertyMetadata(new PropertyChangedCallback(OnNameChanged)));

        private static void OnNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            //TODO journal entry namechanged
        }

        #endregion

        #region NavigationContextAttacheProperty

        public static NavigationContext GetNavigationContext(DependencyObject obj)
        {
            Guard.AreNotNull(obj, "obj");
            return (NavigationContext)obj.GetValue(NavigationContextProperty);
        }

        public static void SetNavigationContext(DependencyObject obj, NavigationContext value)
        {
            Guard.AreNotNull(obj, "obj");
            obj.SetValue(NavigationContextProperty, value);
        }

        public NavigationContext NavigationContext
        {
            get { return (NavigationContext)GetValue(NavigationContextProperty); }
            set { SetValue(NavigationContextProperty, value); }
        }


        public static readonly DependencyProperty NavigationContextProperty =
            DependencyProperty.RegisterAttached("NavigationContext", typeof(NavigationContext), typeof(JournalEntry), null);


        #endregion

        public JournalEntry(string name, Uri source)
        {
            Guard.AreNotNull(source, "source");
            this.Name = name;
            this._source = source;
        }

    }
}
